using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PatientDomain;
//using ShivamEMR.Web.Areas.Patient.Models;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Patient.Controllers
{   
    public class TreatmentStatusController : Controller
    {
		private readonly ITreatmentStatusRepository treatmentstatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public TreatmentStatusController() //: this(new TreatmentStatusRepository())
        {
            this.treatmentstatusRepository = Registry.RepositoryFactory.GetTreatmentStatusRepository();
        }

        public TreatmentStatusController(ITreatmentStatusRepository treatmentstatusRepository)
        {
			this.treatmentstatusRepository = treatmentstatusRepository;
        }

        //
        // GET: /TreatmentStatus/

        public ViewResult Index()
        {
            return View(treatmentstatusRepository.All);//Including(treatmentstatus => treatmentstatus.Treatments));
        }

        //
        // GET: /TreatmentStatus/Details/5

        public ViewResult Details(int id)
        {
            return View(treatmentstatusRepository.Find(id));
        }

        //
        // GET: /TreatmentStatus/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /TreatmentStatus/Create

        [HttpPost]
        public ActionResult Create(TreatmentStatus treatmentstatus)
        {
            if (ModelState.IsValid) {
                treatmentstatusRepository.Create(treatmentstatus);
                treatmentstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /TreatmentStatus/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(treatmentstatusRepository.Find(id));
        }

        //
        // POST: /TreatmentStatus/Edit/5

        [HttpPost]
        public ActionResult Edit(TreatmentStatus treatmentstatus)
        {
            if (ModelState.IsValid) {
                treatmentstatusRepository.InsertOrUpdate(treatmentstatus);
                treatmentstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /TreatmentStatus/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(treatmentstatusRepository.Find(id));
        }

        //
        // POST: /TreatmentStatus/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var ts = treatmentstatusRepository.Find(id);
            treatmentstatusRepository.Delete(ts);
            treatmentstatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

